home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 12594 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.1 KB

  1. Path: morse.ukonline.co.uk!usenet
  2. From: g.tafuro@ukonline.co.uk
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: C++ template
  5. Date: 20 Mar 1996 17:35:24 GMT
  6. Organization: UK Online
  7. Message-ID: <4ipfks$7om@morse.ukonline.co.uk>
  8. References: <4in2p7$27b@calvin.st-and.ac.uk>
  9. NNTP-Posting-Host: wwwproxy.ukonline.co.uk
  10.  
  11. Usually all the code related a templated class has to be in a header file
  12. (.Hxx).
  13. The reason is that the compiler has to substitute the formal parameter (<T>)
  14. with the actual object.
  15.  
  16. I suggest you to put all the code (related to the class) in just one header
  17. file.
  18. The code seems to be OK. If you accept an other advice, you should provide
  19. to your class the following operations:
  20.  
  21. - a virtual destructor;
  22. - a copy constructor;
  23. - a virtual assignment operator.
  24.  
  25. The destructor is important because, if properly built, cleans up the memory
  26. avoiding memory leaking.
  27. The other operations are important because most compilers will create them
  28. even if you do not declare them.
  29. If you do not like that the users can use the copy constructor or the assignment
  30. operator, you should make them private.
  31.  
  32. Hope this helps.
  33.  
  34. Gabriele Tafuro
  35. g.tafuro@ukonline.co.uk
  36.